<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录</title>
    <!-- CSS -->
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
    <link rel="stylesheet" href="/static/login/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/login/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/login/css/form-elements.css">
    <link rel="stylesheet" href="/static/login/css/style.css">
    <link rel="stylesheet" href="/static/layer/layui.css">
    <link rel="stylesheet" href="/static/layer/theme/default/layer.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- Favicon and touch icons -->
    <link rel="shortcut icon" href="/static/login/ico/favicon.png">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/login/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/login/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/login/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="/static/login/ico/apple-touch-icon-57-precomposed.png">
    <style type="text/css">
        #bg{ display: none;  position: absolute;  top: 0%;  left: 0%;  width: 100%;  height: 100%;  background-color: #a2a2a2;  z-index:1001;  -moz-opacity: 0.7;  opacity:.70;  filter: alpha(opacity=70);}
        #show{display: none;  position: absolute;  top: 25%;  left: 38%;  width: auto;  height: auto; border: 7px solid rgba(255, 31, 31, 0.2);  z-index:1002;  overflow: auto;}
    </style>
</head>
<body>
<div id="bg"></div>
<div id="show">
    <img src="../static/layer/img/11342112.gif">
    <font size="5"  style="position: absolute;left: 22%;text-align: center;bottom: 0">
        注册成功！<b class="time" id="time" style="color: red">3</b> 秒后<a href="/view/login.html" style="color: blue">跳转</a>！</font>
</div>
<div class="top-content">
    <div class="inner-bg">
        <div class="container">
            <div class="row">
                <div class="col-sm-8 col-sm-offset-2 text">
                    <h1><strong>注册</strong></h1>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6 col-sm-offset-3 form-box">
                    <div class="form-top">
                        <div class="form-top-left">
                            <h3></h3>
                            <p>输入您的用户名和密码注册：</p>
                        </div>
                        <div class="form-top-right">
                            <i class="fa fa-lock"></i>
                        </div>
                    </div>
                    <div class="form-bottom">
                        <form role="form" method="post" class="login-form">
                            <div class="form-group">
                                <label class="sr-only" for="username">Username</label>
                                <input type="text" name="userName" placeholder="用户名..." class="form-username form-control" id="username">
                            </div>
                            <div class="form-group">
                                <label class="sr-only" for="nikeName">NikeName</label>
                                <input type="text" name="nikeName" placeholder="姓名..." class="form-password form-control" id="nikeName">
                            </div>
                            <div class="form-group">
                                <label class="sr-only" for="password">Password</label>
                                <input type="password" name="password" placeholder="密码..." class="form-password form-control" id="password">
                            </div>
                            <button type="button" class="btn" style="background: #767202;" onclick="register()">注册</button>
                        </form>
                        <button type="button" style="margin-top: 10px;width: 100%;background:#14520c" class="btn retrunIndex">返回</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Javascript -->
<script src="/static/login/js/jquery-1.11.1.min.js"></script>
<script src="/static/login/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/login/js/jquery.backstretch.min.js"></script>
<script src="/static/login/js/registerScripts.js"></script>
<script src="/static/layer/layer.js"></script>
<!--[if lt IE 10]>
<script src="/static/login/js/placeholder.js"></script>
<![endif]-->
</body>
<script>
//    跳转注册页面
    $(".retrunIndex").on("click",function () {
        location.href="/view/login.html";
    });
    
    function register() {
        var userName = $("#username").val();
        var password = $("#password").val();
        var nikeName = $("#nikeName").val();

        if(isNull(userName)||isNull(password)){
            return;
        }

        $.ajax({
            type:"post",
            url:"/registerUser",
            data:{
              userName:userName,
              password:password,
              nikeName:nikeName
            },
            success:function (data) {
                if(data.code==0){
                    showdiv();
                }else{
                    layer.msg(data.desc, {icon: 5});
                }
            }
        })
    }

    function showdiv() {
        document.getElementById("bg").style.display ="block";
        document.getElementById("show").style.display ="block";
        times();
    }

    function times(){
        setInterval(function() {
            var s = $("#time").html();
            s--;
            $("#time").html(s);
            if(s == 0) {
                location.href="/view/login.html";
            }
        }, 1000);
    }

    function isNull(temp) {
        if (!temp && temp !== 0) {
            return true;
        }
        return false;
    }
</script>
</html>